package scjp.preparation.exam;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Formatter;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

public class TestDerived {

	public enum State {
		ONCALL, IDLE, WAITING
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Base1 obj1 = new Derived1();
		Base1 obj2 = (Base1) obj1;
		obj1.print();
		obj2.print();

		String test = "I am preparing for OCPJP";
		String[] tokens = test.split("\\s");
		System.out.println(tokens.length);
		for (String s : tokens) {
			System.out.println(s);
		}

		TestDerived test1 = new TestDerived();
		test1.print(10);

		TestDerived.State state = TestDerived.State.ONCALL;
		System.out.println("------------");
		Deri b = new Deri();
		b.getVal((int) 1L);
		
		Deque<String> deque = new ArrayDeque<String>(1);
		Queue<String> q = new ArrayBlockingQueue<String>(10);
		deque.addFirst("one ");
		deque.addFirst("two ");
		deque.addFirst("three ");
		System.out.print(deque.poll());
		System.out.print(deque.poll());
		System.out.print(deque.poll());
//		q.add("one");
//		q.add("two");
//		System.out.println(q.poll());
//		System.out.println(q.poll());
		String s = String.format("%s, %s, %b", 5, 2.12, false);
		System.out.println(s);
	}

	public void print(Integer i) {
		System.out.println("Integer");
	}

	public void print(int i) {
		System.out.println("int");
	}

	public void print(long i) {
		System.out.println("long");
	}

}

class Base1 {
	public void print() {
		System.out.println("Base");
	}
}

class Derived1 extends Base1 {
	public void print() {
		System.out.println("Derived");
	}
}

abstract class Base2 {
	public abstract Number getValue();
	public String getVal(int i) {
		System.out.println("int");
		return null;}
}

class Deri extends Base2 {
	public java.util.concurrent.atomic.AtomicInteger getValue() {
		return new java.util.concurrent.atomic.AtomicInteger(10);
		}
}